﻿@using Microsoft.Extensions.Options
@model WidgetBase
@{
    Script.Reqiured("validate").AtFoot();
    Script.Reqiured("tinymce").AtFoot();
}
<div class="panel panel-default">
    <div class="panel-heading">
        <div>
            @ViewBag.WidgetTemplateName
        </div>
    </div>
    <div class="panel-body">
        @using (Html.BeginForm())
        {
            if (Model.DataSourceLink.IsNotNullAndWhiteSpace())
            {
                <div class="form-horizontal">
                    <div class="form-group">
                        <div class="col-md-12 col-lg-2">
                            <label class="control-label">@L("内容来源")</label>
                        </div>
                        <div class="col-md-12 col-lg-10">
                            <a href="@Url.PathContent(Model.DataSourceLink)" class="btn btn-link" style="padding-left:0">@L(Model.DataSourceLinkTitle)</a>
                            <code>@L("页面展现的内容")</code>
                        </div>
                    </div>
                </div>
            }
            @Html.EditorForModel()
            <input type="hidden" name="ReturnUrl" value="@ViewBag.ReturnUrl" />
            <div class="toolBar">
                <input id="design" type="submit" class="btn btn-primary" value="@L("保存")" data-value="@ActionType.Update" />
                @if (Model.IsTemplate && Model.Thumbnail.IsNotNullAndWhiteSpace())
                {
                    <a href="@Url.Action("Pack", new {Model.ID})" class="btn btn-success">
                        <i class="glyphicon glyphicon-save-file"></i>
                        @L("打包模板")
                    </a>
                }
                <input id="copy-widget" type="button" class="btn btn-warning" data-id="@Model.ID" value="@L("复制")" />
                <input type="button" class="btn btn-default cancel" value="@L("取消")" />
            </div>
        }
    </div>
</div>
@using (Script.AtFoot())
{
    <script type="text/javascript">
        $(function () {
            $(document).on("click", "#copy-widget", function () {
                $.post("@Url.Action("Copy","Widget",new{module="admin"})", { widgetId: $(this).data("id") }, function (data) {
                    Easy.MessageTip.Show(data.message);
                });
            });
        });
    </script>
}